<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "customer".
 *
 * @property int $id
 * @property int $shop_id 门店id
 * @property string $name 姓名
 * @property string $phone 手机号
 * @property string $nickname 微信昵称
 * @property string $icon 头像
 * @property string $openid openid
 * @property int $status 状态
 * @property int $created_at 创建时间
 */
class Customer extends Base
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'customer';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['shop_id', 'status', 'created_at'], 'integer'],
            [['nickname', 'name', 'phone', 'password', 'icon', 'openid'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'phone' => 'Phone',
            'nickname' => 'Nickname',
            'icon' => 'Icon',
            'openid' => 'Openid',
            'status' => 'Status',
            'created_at' => 'Created At',
        ];
    }

    public function getShop(){
        return $this->hasOne(Shop::class, ['id' => 'shop_id']);
    }
}
